#include <iostream>
using namespace std;

int main() {
    int Monthday[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    int year,month,day;
    cin>>year>>month>>day;
    for(int i=1;i<month;i++) 
    {
        day+=Monthday[i];      
    }
      if((year%400==0||(year%4==0&&year%100!=0))&&month>2)
        {
            day++;
        }
    cout<<day<<endl;
}
